<%-- 
    Document   : head_index
    Created on : Jan 7, 2012, 6:35:55 PM
    Author     : Ngoc Linh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<title>Thông tin chung - Quản trị P2TBid</title>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type='text/javascript' src='/DauGia/dwr/engine.js'></script>
<script type='text/javascript' src='/DauGia/dwr/interface/daugia.js'></script>

<script type='text/javascript'>        
    google.load('visualization', '1', { 
        'packages': ['columnchart', 'piechart'] 
    });

    google.setOnLoadCallback(createChart); 

    function createChart() { 
        var dataTable = new google.visualization.DataTable();
        dataTable.addColumn('string', 'Tháng');
        dataTable.addColumn('number', 'Thành viên'); 
        dataTable.addRows([
            <c:if test="${sessionScope.thongKeDangKy ne null}">
                <c:forEach var="i" begin="0" end="10" step="1">
                    ['T${i + 1}', ${sessionScope.thongKeDangKy[i]}],
                </c:forEach>
            </c:if> 
            ['T12', ${sessionScope.thongKeDangKy[11]}]
        ]); 
        
        var chart = new google.visualization.ColumnChart(document.getElementById('ad_chart_accout')); 
        var options = { width: 425, height: 325, is3D: true };
        chart.draw(dataTable, options); 
    }
</script>
<script type='text/javascript'>        
    google.load('visualization', '1', {
        'packages': ['piechart'] 
    });

    google.setOnLoadCallback(createChart);

    function createChart() { 
        var dataTable = new google.visualization.DataTable();
        dataTable.addColumn('string', 'Danh mục'); 
        dataTable.addColumn('number', 'Sản phẩm');
        dataTable.addRows([
            <c:if test="${sessionScope.thongkeSanPham ne null}">
                <c:forEach var="i" begin="0" end="${sessionScope.thongkeSanPham.size() - 2}" step="1">
                    <c:set var="item" value="${sessionScope.thongkeSanPham[i]}" />
                    ['${item.tenDanhMuc}', ${item.sanphams.size()}],
                </c:forEach>
                <c:set var="item1" value="${sessionScope.thongkeSanPham[sessionScope.thongkeSanPham.size() - 1]}" />
                ['${item1.tenDanhMuc}', ${item1.sanphams.size()}]
            </c:if>              
        ]);
        
        var chart = new google.visualization.PieChart(document.getElementById('ad_total_user')); 
        var options = { width: 425, height: 280, is3D: true }; chart.draw(dataTable, options);
    }
</script>
<script type="text/javascript">
    
    function  GetNews(){
        daugia.LayTinTucCapNhat(function(data){
            
            if(data != null){
                var innerHtml = "";
                
                for(var i=0; i < data.length; i ++){
                    innerHtml += '<p>' + data[i] + '</p>';
                }
                
                $('#ad_messagesys').html(innerHtml).hide().delay(800).slideDown('slow');
            }  
            
            window.setTimeout('GetNews()', 20000);
        });
    }
    
    window.onload = function() { 
        GetNews(); 
    }
    
</script>
